# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=traitlets
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}" "${MINGW_PACKAGE_PREFIX}-python2-${_realname}")
pkgver=4.3.2
pkgrel=2
pkgdesc="A lightweight Traits like module (mingw-w64)"
url="https://github.com/ipython/traitlets"
arch=('any')
license=('Modified BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python3-nose"
              "${MINGW_PACKAGE_PREFIX}-python2-nose")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/ipython/${_realname}/archive/${pkgver}.tar.gz")
sha256sums=('370f938ad730d52272ef74f96f831cb21138f6168e46fe582fe256c35cc656ce')


prepare() {
  cp -a ${_realname}-${pkgver}{,-py2}
}

build() {
  cd ${srcdir}/${_realname}-${pkgver}
  python3 setup.py build

  cd ${srcdir}/${_realname}-${pkgver}-py2
  python2 setup.py build
}

check() {
    cd ${srcdir}/${_realname}-${pkgver}/${_realname}/tests
    nosetests-3.6 test_traitlets.py

    cd ${srcdir}/${_realname}-${pkgver}-py2/${_realname}/tests
    nosetests-2.7 test_traitlets.py
}

package_python3-traitlets() {
  depends=(
    "${MINGW_PACKAGE_PREFIX}-python3-ipython_genutils"
    "${MINGW_PACKAGE_PREFIX}-python3-decorator"
  )

  cd ${srcdir}/${_realname}-${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1
  install -Dm644 COPYING.md ${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE
}

package_python2-traitlets() {
  depends=(
    "${MINGW_PACKAGE_PREFIX}-python2-ipython_genutils"
    "${MINGW_PACKAGE_PREFIX}-python2-decorator"
  )

  cd ${srcdir}/${_realname}-${pkgver}-py2
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1
  install -Dm644 COPYING.md ${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE
}

package_mingw-w64-i686-python2-traitlets() {
  package_python2-traitlets
}

package_mingw-w64-i686-python3-traitlets() {
  package_python3-traitlets
}

package_mingw-w64-x86_64-python2-traitlets() {
  package_python2-traitlets
}

package_mingw-w64-x86_64-python3-traitlets() {
  package_python3-traitlets
}

# vim:set ts=2 sw=2 et:
